package com.maochd.cloud.excel.controller;

import com.maochd.cloud.common.core.domain.R;
import com.maochd.cloud.excel.constant.ExcelConstant;
import com.maochd.cloud.excel.service.ImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/import")
@Api(tags = "导入适配器")
public class ImportController {

    @Resource
    private ImportService importService;

    @PostMapping(value = "/adapter")
    @ApiOperation(value = "导入适配器")
    public R<String> importAdapter(@RequestParam("file") MultipartFile file,
                                   @RequestParam("importType") Integer type) {
        importService.importAdapter(file, type);
        return R.ok(ExcelConstant.IMPORT_TEXT);
    }
}
